using System;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace SilverSea.Video.Tools
{
	public class CameraDescriptionPage : UserControl, IWizardPage
	{
		private IContainer icontainer_0;
		private ComboBox cbxVideoSource;
		private Label label3;
		private TextBox txtDescription;
		private Label label2;
		private TextBox txtName;
		private Label label1;
		private EventHandler eventHandler_0;
		private EventHandler eventHandler_1;
		private Camera camera_0;
		private CheckCameraHandler checkCameraHandler_0;
		private bool bool_0;
		public event EventHandler StateChanged
		{
			add
			{
				EventHandler eventHandler = this.eventHandler_0;
				EventHandler eventHandler2;
				do
				{
					eventHandler2 = eventHandler;
					EventHandler value2 = (EventHandler)Delegate.Combine(eventHandler2, value);
					eventHandler = Interlocked.CompareExchange<EventHandler>(ref this.eventHandler_0, value2, eventHandler2);
				}
				while (eventHandler != eventHandler2);
			}
			remove
			{
				EventHandler eventHandler = this.eventHandler_0;
				EventHandler eventHandler2;
				do
				{
					eventHandler2 = eventHandler;
					EventHandler value2 = (EventHandler)Delegate.Remove(eventHandler2, value);
					eventHandler = Interlocked.CompareExchange<EventHandler>(ref this.eventHandler_0, value2, eventHandler2);
				}
				while (eventHandler != eventHandler2);
			}
		}
		public event EventHandler Reset
		{
			add
			{
				EventHandler eventHandler = this.eventHandler_1;
				EventHandler eventHandler2;
				do
				{
					eventHandler2 = eventHandler;
					EventHandler value2 = (EventHandler)Delegate.Combine(eventHandler2, value);
					eventHandler = Interlocked.CompareExchange<EventHandler>(ref this.eventHandler_1, value2, eventHandler2);
				}
				while (eventHandler != eventHandler2);
			}
			remove
			{
				EventHandler eventHandler = this.eventHandler_1;
				EventHandler eventHandler2;
				do
				{
					eventHandler2 = eventHandler;
					EventHandler value2 = (EventHandler)Delegate.Remove(eventHandler2, value);
					eventHandler = Interlocked.CompareExchange<EventHandler>(ref this.eventHandler_1, value2, eventHandler2);
				}
				while (eventHandler != eventHandler2);
			}
		}
		public Camera Camera
		{
			get
			{
				return this.camera_0;
			}
			set
			{
				if (value != null)
				{
					this.camera_0 = value;
					this.txtName.Text = this.camera_0.Name;
					this.txtDescription.Text = this.camera_0.Description;
					this.cbxVideoSource.SelectedIndex = (int)this.camera_0.CameraType;
				}
			}
		}
		public int CameraType
		{
			get
			{
				return this.cbxVideoSource.SelectedIndex;
			}
		}
		public CheckCameraHandler CheckCameraFunction
		{
			set
			{
				this.checkCameraHandler_0 = value;
			}
		}
		public string PageName
		{
			get
			{
				return "Tên và chủng loại Camera";
			}
		}
		public string PageDescription
		{
			get
			{
				return "Bước 1: Nhập tên và chọn loại Camera";
			}
		}
		public bool Completed
		{
			get
			{
				return this.bool_0;
			}
		}
		public CameraDescriptionPage()
		{
			this.InitializeComponent();
			this.cbxVideoSource.SelectedIndex = 0;
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.icontainer_0 != null)
			{
				this.icontainer_0.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CameraDescriptionPage));
            this.cbxVideoSource = new System.Windows.Forms.ComboBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txtDescription = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.txtName = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // cbxVideoSource
            // 
            this.cbxVideoSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbxVideoSource.FormattingEnabled = true;
            resources.ApplyResources(this.cbxVideoSource, "cbxVideoSource");
            this.cbxVideoSource.Name = "cbxVideoSource";
            this.cbxVideoSource.Items.AddRange(new object[]
			{
				resources.GetString("cbxVideoSource.Items"),
				resources.GetString("cbxVideoSource.Items1"),
				resources.GetString("cbxVideoSource.Items2"),
				resources.GetString("cbxVideoSource.Items3")
			});
            // 
            // label3
            // 
            resources.ApplyResources(this.label3, "label3");
            this.label3.Name = "label3";
            // 
            // txtDescription
            // 
            resources.ApplyResources(this.txtDescription, "txtDescription");
            this.txtDescription.Name = "txtDescription";
            // 
            // label2
            // 
            resources.ApplyResources(this.label2, "label2");
            this.label2.Name = "label2";
            // 
            // txtName
            // 
            resources.ApplyResources(this.txtName, "txtName");
            this.txtName.Name = "txtName";
            this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
            // 
            // label1
            // 
            resources.ApplyResources(this.label1, "label1");
            this.label1.Name = "label1";
            // 
            // CameraDescriptionPage
            // 
            this.Controls.Add(this.cbxVideoSource);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.txtDescription);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.txtName);
            this.Controls.Add(this.label1);
            this.Name = "CameraDescriptionPage";
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		public void Display()
		{
			this.txtName.Focus();
			this.txtName.SelectionStart = this.txtName.TextLength;
		}
		public bool Apply()
		{
			string name = this.txtName.Text.Trim();
			if (this.checkCameraHandler_0 != null)
			{
				Camera camera = new Camera();
				camera.ID = this.camera_0.ID;
				camera.Name = name;
				if (!this.checkCameraHandler_0(camera))
				{
					System.Drawing.Color backColor = this.txtName.BackColor;
					this.txtName.BackColor = System.Drawing.Color.LightCoral;
					MessageBox.Show(this, "Đã tồn tại Camera với tên này!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
					this.txtName.BackColor = backColor;
					this.txtName.Focus();
					return false;
				}
			}
			this.camera_0.Name = name;
			this.camera_0.Description = this.txtDescription.Text;
			this.camera_0.CameraType = (CameraType)this.cbxVideoSource.SelectedIndex;
			return true;
		}
		private void method_0()
		{
			this.bool_0 = (this.txtName.TextLength != 0 && this.cbxVideoSource.SelectedIndex >= 0);
			if (this.eventHandler_0 != null)
			{
				this.eventHandler_0(this, new EventArgs());
			}
		}
		private void txtName_TextChanged(object sender, EventArgs e)
		{
			this.method_0();
		}
		private void cbxVideoSource_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.method_0();
			if (this.eventHandler_1 != null)
			{
				this.eventHandler_1(this, new EventArgs());
			}
		}
	}
}
